﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Configuration;

public partial class ybqy_sheding : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label3.Text = "";
        if (!Page.IsValid) { return; }

        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from  qiyejibenxingxi where qrm='" + TextBox1.Text.Trim()+ "' and qiyeid=" + Session["qiyeid"], sqlcon);

        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
        string sqlstr = "";

        if (reader.Read())
        {
             sqlstr = "select * from  qiyejibenxingxi where qrm='" + TextBox1.Text.Trim()+ "'";
            sqlcon.Close();
            reader.Close();
            sqlcmd.CommandText = sqlstr;
            reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                Label3.Text = "新登录码不合法，请更换";
            }
            else
            {
                sqlstr = "update  qiyejibenxingxi set qrm='" + TextBox2.Text.Trim() + "' where qrm='" + TextBox1.Text.Trim() + "'";
                sqlcon.Close();
                reader.Close();
                sqlcmd.CommandText = sqlstr;
           
            }
        }
 

    }
}